import {Component, Input, OnInit} from '@angular/core';
import {AlertService} from "../../../../services/alert.service";
import {AdminService} from "../../../../services/admin.service";
import {BakeRecord} from "../../../../model/BakeRecord";
import {AuthService} from "../../../../services/auth.service";

@Component({
  selector: 'app-bakerecordedit',
  templateUrl: './bakerecordedit.component.html',
  styleUrls: ['./bakerecordedit.component.css']
})
export class BakerecordeditComponent implements OnInit {
@Input()id:string
  b:BakeRecord

  constructor(  private adminService:AdminService,private alertService:AlertService,
                private authService:AuthService) {
    this.b = new BakeRecord()

  }

  ngOnInit(): void {
  this.getBakeRecord()

  }

  getBakeRecord(){
  this.adminService.getBakerecordByid(this.id).then((data:any)=>{
    if(data.msg =="ok"){
      this.b = data.obj
    }else{
      this.alertService.showError("根据id获取烘焙记录失败")
    }
  })
  }

/*  gethbrArray(){
    this.authService.getMemberListByRole("292a0514fc814c2a8f42bcd9493e4794").then((data:any)=>{
      if(data.msg == "ok"){
        this.hbrArray = data.list
      }else{
        this.alertService.showError("获取烘焙人数组失败")
      }
    })
  }*/

save(){
  this.adminService.saveBakerecord(this.b).then((data:any)=>{
    if(data.msg =="ok"){
      this.alertService.showSuccess("设置烘焙记录成功")
    }else{
      this.alertService.showError("设置烘焙记录失败")
    }
  })
}
}
